<?php
define("Yii_BT_TIME", time());
$_project_root = dirname(dirname(__DIR__));
Yii::setAlias('@project_dir', $_project_root); // 根目录
Yii::setAlias('@common', $_project_root . '/common');
Yii::setAlias('@data', $_project_root . '/data');
Yii::setAlias('@home', $_project_root . '/home');
Yii::setAlias('@admin', $_project_root . '/admin');
Yii::setAlias('@appapi', $_project_root . '/appapi');
Yii::setAlias('@webapi', $_project_root . '/webapi');
Yii::setAlias('@wechatapi', $_project_root . '/wechatapi');
Yii::setAlias('@console', $_project_root . '/console');

Yii::setAlias('@wroot', $_project_root . '/web');
Yii::setAlias('@wurl', '/');
Yii::setAlias('@storage_root', $_project_root . '/web/storage');
Yii::setAlias('@storage_url', '/storage');
Yii::setAlias('@tmp_root', $_project_root . '/web/storage/tmp');
Yii::setAlias('@tmp_url', '/storage/tmp');

//Yii::$classMap['yii\helpers\Markdown'] = '@common/helpers/Markdown.php';

Yii::$container->set(\yii\data\Pagination::class, [
//    'totalCount', //为数据总数,
    'pageSize' => 10, //为每页显示数,
//    'pageSizeParam'=>false, //可将分页路径中per-page参数隐藏去掉,
//    'pageParam' => 'p', //可更改分页url中分页参数name名称,
//    'route' => false, //分页在于首页时隐藏掉路由，将/site/index?p=1变为/?p=1,
//    'validatePage' => false, //取消分页验证,当手动输入page=20时不再跳到page=1,
]);
Yii::$container->set(\yii\widgets\LinkPager::class, [
    'maxButtonCount' => 9, 
    'firstPageLabel' => '首页', 
    'lastPageLabel' => '末页',
    'prevPageLabel'=>'上一页', 
    'nextPageLabel'=>'下一页',
]);
Yii::$container->set(\common\rewrite\widgets\LinkPager::class, [
    'maxButtonCount' => 9,
    'firstPageLabel' => '首页',
    'lastPageLabel' => '末页',
    'prevPageLabel'=>'上一页',
    'nextPageLabel'=>'下一页',
]);
Yii::$container->set(\yii\widgets\Pjax::class, [
    'timeout' => false,
]);
Yii::$container->set(\yii\captcha\CaptchaAction::class, [
    'minLength' => 4, 
    'maxLength' => 4, 
    'fontFile' => '@data/fonts/ztgjkt.ttf',
]);
Yii::$container->set(\yii\captcha\Captcha::class, [
    'captchaAction' => "/site/captcha",
    'imageOptions' => [
        'alt'=>'点击换图',
        'title'=>'点击换图',
        'style'=>'cursor:pointer',
    ],
]);
Yii::$container->set(\yii\bootstrap\Modal::class, [
    'size' => \yii\bootstrap\Modal::SIZE_LARGE,
]);
Yii::$container->set(\dosamigos\tinymce\TinyMce::class, [
    'options' => ['rows' => 6],
    'language' => 'zh_CN',
    'clientOptions' => [
        'plugins' => [
            "advlist autolink lists link charmap print preview anchor",
            "searchreplace visualblocks code fullscreen",
            "insertdatetime media table contextmenu paste"
        ],
        'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
    ],
]);
Yii::$container->set(\kriss\wangEditor\WangEditorWidget::class, [
    'clientJs' => "{name}.customConfig.uploadImgServer = '".\common\config\Env::getUrls()['webapi_url']."/public/upload-pics-for-wangeditor';{name}.customConfig.zIndex = 100",
    'canFullScreen' => true,
]);
Yii::$container->set(\kartik\icons\FontAwesomeAsset::class, [
    'js' => [],
    'css' => [
        'https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css',
    ],
]);
Yii::$container->set(\common\components\behaviors\UUIDBehavior::class, [
    'column' => "uuid",
]);

/**
 * debug工具栏输出变量
 * 需要composer安装yii2-debug-vardumper
 * @param $dump
 */
function dump($dump)
{
    \common\members\wodrow\tools\Tools::yiiDebugDump($dump);
}